package com.ruoyi.hr.controller.hr.entryexitmanage.entrymanage;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.service.entryexitmanage.entrymanage.EntryBackgroundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 入职背景
 * @date 2020/3/4
 */
@Controller
@RequestMapping("/entryManage/EntryBackground")
public class EntryBackgroundController extends BaseController {

    private String prefix = "hr/entryexitmanage/entrymanage";

    @Autowired
    EntryBackgroundService entryBackgroudService;

    /**
     * 获取教育信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/getEducationList")
    @ResponseBody
    public TableDataInfo getEducationList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getEducationList(id);
        return getDataTable(map);
    }

    @GetMapping("/addEducation")
    public String addEducation(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/education/add";
    }

    @RequestMapping("/addEducation")
    @ResponseBody
    public AjaxResult addEducation(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addEducation(map));
    }

    @GetMapping("/editEducation")
    public String editEducation(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("education", entryBackgroudService.getEducation(id));
        return prefix + "/education/edit";
    }

    @RequestMapping("/editEducation")
    @ResponseBody
    public AjaxResult editEducation(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editEducation(map));
    }

    @RequestMapping("/deleteEducation")
    @ResponseBody
    public AjaxResult deleteEducation(String allId) {
        return toAjax(entryBackgroudService.deleteEducation(allId));
    }

    /**
     * 获取工作经历
     *
     * @param id
     * @return
     */
    @RequestMapping("/getWorkingList")
    @ResponseBody
    public TableDataInfo getWorkingList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getWorkingList(id);
        return getDataTable(map);
    }

    @GetMapping("/addWorking")
    public String addWorking(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/working/add";
    }

    @RequestMapping("/addWorking")
    @ResponseBody
    public AjaxResult addWorking(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addWorking(map));
    }

    @GetMapping("/editWorking")
    public String editWorking(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("working", entryBackgroudService.getWorking(id));
        return prefix + "/working/edit";
    }

    @RequestMapping("/editWorking")
    @ResponseBody
    public AjaxResult editWorking(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editWorking(map));
    }

    @RequestMapping("/deleteWorking")
    @ResponseBody
    public AjaxResult deleteWorking(String allId) {
        return toAjax(entryBackgroudService.deleteWorking(allId));
    }

    /**
     * 获取职称/资格证书
     *
     * @param id
     * @return
     */
    @RequestMapping("/getTitleList")
    @ResponseBody
    public TableDataInfo getTitleList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getTitleList(id);
        return getDataTable(map);
    }

    @GetMapping("/addTitle")
    public String addTitle(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/title/add";
    }

    @RequestMapping("/addTitle")
    @ResponseBody
    public AjaxResult addTitle(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addTitle(map));
    }

    @GetMapping("/editTitle")
    public String editTitle(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("title", entryBackgroudService.getTitle(id));
        return prefix + "/title/edit";
    }

    @RequestMapping("/editTitle")
    @ResponseBody
    public AjaxResult editTitle(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editTitle(map));
    }

    @RequestMapping("/deleteTitle")
    @ResponseBody
    public AjaxResult deleteTitle(String allId) {
        return toAjax(entryBackgroudService.deleteTitle(allId));
    }

    /**
     * 获取培训经历
     *
     * @param id
     * @return
     */
    @RequestMapping("/getTrainingList")
    @ResponseBody
    public TableDataInfo getTrainingList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getTrainingList(id);
        return getDataTable(map);
    }

    @GetMapping("/addTraining")
    public String addTraining(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/training/add";
    }

    @RequestMapping("/addTraining")
    @ResponseBody
    public AjaxResult addTraining(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addTraining(map));
    }

    @GetMapping("/editTraining")
    public String editTraining(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("training", entryBackgroudService.getTraining(id));
        return prefix + "/training/edit";
    }

    @RequestMapping("/editTraining")
    @ResponseBody
    public AjaxResult editTraining(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editTraining(map));
    }

    @RequestMapping("/deleteTraining")
    @ResponseBody
    public AjaxResult deleteTraining(String allId) {
        return toAjax(entryBackgroudService.deleteTraining(allId));
    }

    /**
     * 获取项目经历
     *
     * @param id
     * @return
     */
    @RequestMapping("/getProjectList")
    @ResponseBody
    public TableDataInfo getProjectList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getProjectList(id);
        return getDataTable(map);
    }

    @GetMapping("/addProject")
    public String addProject(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/project/add";
    }

    @RequestMapping("/addProject")
    @ResponseBody
    public AjaxResult addProject(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addProject(map));
    }

    @GetMapping("/editProject")
    public String editProject(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("project", entryBackgroudService.getProject(id));
        return prefix + "/project/edit";
    }

    @RequestMapping("/editProject")
    @ResponseBody
    public AjaxResult editProject(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editProject(map));
    }

    @RequestMapping("/deleteProject")
    @ResponseBody
    public AjaxResult deleteProject(String allId) {
        return toAjax(entryBackgroudService.deleteProject(allId));
    }

    /**
     * 获取惩奖经历
     *
     * @param id
     * @return
     */
    @RequestMapping("/getHortationList")
    @ResponseBody
    public TableDataInfo getHortationList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getHortationList(id);
        return getDataTable(map);
    }

    @GetMapping("/addHortation")
    public String addHortation(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/hortation/add";
    }

    @RequestMapping("/addHortation")
    @ResponseBody
    public AjaxResult addHortation(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addHortation(map));
    }

    @GetMapping("/editHortation")
    public String editHortation(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("hortation", entryBackgroudService.getHortation(id));
        return prefix + "/hortation/edit";
    }

    @RequestMapping("/editHortation")
    @ResponseBody
    public AjaxResult editHortation(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editHortation(map));
    }

    @RequestMapping("/deleteHortation")
    @ResponseBody
    public AjaxResult deleteHortation(String allId) {
        return toAjax(entryBackgroudService.deleteHortation(allId));
    }

    /**
     * 获取家庭背景
     *
     * @param id
     * @return
     */
    @RequestMapping("/getFamilyList")
    @ResponseBody
    public TableDataInfo getFamilyList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getFamilyList(id);
        return getDataTable(map);
    }

    @GetMapping("/addFamily")
    public String addFamily(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/family/add";
    }

    @RequestMapping("/addFamily")
    @ResponseBody
    public AjaxResult addFamily(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addFamily(map));
    }

    @GetMapping("/editFamily")
    public String editFamily(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("family", entryBackgroudService.getFamily(id));
        return prefix + "/family/edit";
    }

    @RequestMapping("/editFamily")
    @ResponseBody
    public AjaxResult editFamily(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editFamily(map));
    }

    @RequestMapping("/deleteFamily")
    @ResponseBody
    public AjaxResult deleteFamily(String allId) {
        return toAjax(entryBackgroudService.deleteFamily(allId));
    }

    /**
     * 获取语言能力
     *
     * @param id
     * @return
     */
    @RequestMapping("/getLanguageList")
    @ResponseBody
    public TableDataInfo getLanguageList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getLanguageList(id);
        return getDataTable(map);
    }

    @GetMapping("/addLanguage")
    public String addLanguage(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/language/add";
    }

    @RequestMapping("/addLanguage")
    @ResponseBody
    public AjaxResult addLanguage(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addLanguage(map));
    }

    @GetMapping("/editLanguage")
    public String editLanguage(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("language", entryBackgroudService.getLanguage(id));
        return prefix + "/language/edit";
    }

    @RequestMapping("/editLanguage")
    @ResponseBody
    public AjaxResult editLanguage(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editLanguage(map));
    }

    @RequestMapping("/deleteLanguage")
    @ResponseBody
    public AjaxResult deleteLanguage(String allId) {
        return toAjax(entryBackgroudService.deleteLanguage(allId));
    }

    /**
     * 获取紧急联系人
     *
     * @param id
     * @return
     */
    @RequestMapping("/getEmergencyList")
    @ResponseBody
    public TableDataInfo getEmergencyList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getEmergencyList(id);
        return getDataTable(map);
    }

    @GetMapping("/addEmergency")
    public String addEmergency(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/emergency/add";
    }

    @RequestMapping("/addEmergency")
    @ResponseBody
    public AjaxResult addEmergency(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addEmergency(map));
    }

    @GetMapping("/editEmergency")
    public String editEmergency(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("emergency", entryBackgroudService.getEmergency(id));
        return prefix + "/emergency/edit";
    }

    @RequestMapping("/editEmergency")
    @ResponseBody
    public AjaxResult editEmergency(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editEmergency(map));
    }

    @RequestMapping("/deleteEmergency")
    @ResponseBody
    public AjaxResult deleteEmergency(String allId) {
        return toAjax(entryBackgroudService.deleteEmergency(allId));
    }

    /**
     * 获取紧急联系人
     *
     * @param id
     * @return
     */
    @RequestMapping("/getCertificateList")
    @ResponseBody
    public TableDataInfo getCertificateList(String id) {
        startPage();
        List<Map<String, Object>> map = entryBackgroudService.getCertificateList(id);
        return getDataTable(map);
    }

    @GetMapping("/addCertificate")
    public String addCertificate(String id, ModelMap mmap) {
        mmap.put("id", id);
        return prefix + "/certificate/add";
    }

    @RequestMapping("/addCertificate")
    @ResponseBody
    public AjaxResult addCertificate(@RequestParam Map map) {
        return toAjax(entryBackgroudService.addCertificate(map));
    }

    @GetMapping("/editCertificate")
    public String editCertificate(String id, ModelMap mmap) {
        //根据ID取单条数据
        mmap.put("emergency", entryBackgroudService.getCertificate(id));
        return prefix + "/certificate/edit";
    }

    @RequestMapping("/editCertificate")
    @ResponseBody
    public AjaxResult editCertificate(@RequestParam Map map) {
        return toAjax(entryBackgroudService.editCertificate(map));
    }

    @RequestMapping("/deleteCertificate")
    @ResponseBody
    public AjaxResult deleteCertificate(String allId) {
        return toAjax(entryBackgroudService.deleteCertificate(allId));
    }
}
